//
//  ViewController.m
//  UI29_homeBlock
//
//  Created by dllo on 16/1/20.
//  Copyright © 2016年 Yuming. All rights reserved.
//

#import "ViewController.h"
#import "SecoundViewController.h"
#import "TouchView.h"
#import "NotwrokingHandle.h"


@interface ViewController ()
@property (weak, nonatomic) IBOutlet UILabel *laberOfText;

@property (weak, nonatomic) IBOutlet UITextField *textFile;

@property (nonatomic, retain) NSString *text;

@property (weak, nonatomic) IBOutlet TouchView *touchView;

@end

@implementation ViewController

- (instancetype)init {
    static ViewController *vc = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        vc = self;
    });
    return vc;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
   
    [self.touchView viewDidClick:^(TouchView *view) {
        NSLog(@"点击我了.");
    }];
    
    [self.touchView buttonHandle:^(UIButton *deleBtn) {
        NSLog(@"点击了删除按键.");
    }];
    
    [self.touchView editBtnHandle:^(UIButton *editBtn) {
        NSLog(@"点击了编辑按键");
    } deleButnHandle:^(UIButton *deleBtn) {
        NSLog(@"点击了删除按键");
    }];
    
    [self handleData];
}

#pragma mark - 数据处理(网路类使用block回调)
- (void)handleData{

    NSString *str = @"http://api.map.baidu.com/place/v2/search?query=银行&region=大连&output=json&ak=6E823f587c95f0148c19993539b99295";
    
    [NotwrokingHandle networkingWithURL:str completeHandle:^(NSURLResponse *response, NSData *data, id result) {
        NSLog(@"%@",result);
    }];


}




/** 实现可视化方法 */
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {

    //获取第二界面的对象.
    
    SecoundViewController *second = segue.destinationViewController;
    __weak typeof(self)weakSelf = self;
    second.block = ^(NSString *str){
        weakSelf.laberOfText.text = str;
    };


}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
